package com.arsl.client.presenter;

import com.arsl.client.GlobalInfo;
import com.arsl.client.PaperaziServiceAsync;
import com.arsl.client.data.Paper;
import com.arsl.client.view.ManagePaperView;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.HasWidgets;

public class ManagePaperPresenter implements Presenter {

	ManagePaperView view;

	public ManagePaperPresenter(final ManagePaperView view) {
		this.view = view;
		GlobalInfo.rpcService.getPapers(GlobalInfo.publisherId,
				new AsyncCallback<Paper[]>() {

					@Override
					public void onSuccess(Paper[] result) {
						view.loadPapers(result);
					}

					@Override
					public void onFailure(Throwable caught) {
						// TODO Auto-generated method stub

					}
				});
	}

	@Override
	public void go(HasWidgets container) {
		container.clear();
		container.add(view);
	}

}
